package com.ctgu.j08.controller;

import com.ctgu.j08.service.TroubleService;
import com.ctgu.j08.vo.DUser;
import com.ctgu.j08.vo.Result;
import com.ctgu.j08.vo.Trouble;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @author: Saiya Wang
 * @date: 2021/6/3 9:51
 */
@Controller
@RequestMapping("/trouble")
public class TroubleController {
    @Autowired
    private TroubleService troubleService;

    @PostMapping("/add")
    @ApiOperation("添加报修信息")
    @ResponseBody
    public Result addTrouble(@RequestBody Trouble trouble){
        System.out.println("添加的用户"+trouble);
        return troubleService.addTrouble(trouble);
    }

    @PutMapping("/edit")
    @ApiOperation("更新报修信息")
    @ResponseBody
    public Result editTrouble(@RequestBody Trouble trouble)
    {
        return troubleService.editTrouble(trouble);
    }

    @GetMapping("/getAll")
    @ApiOperation("获取全部报修信息")
    @ResponseBody
    public Result getAllTroubleInfo()
    {
        return troubleService.getAllTroubleInfo();
    }

}
